From: Chong Yidong Date: Tue, 20 Mar 2012 15:44:45 +0000 (+0800) Subject: Improve column width calculation in tabulated-list.el. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~324^2~411 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=f80cd23670a5bf4f603298279fae2f3cde3ab4af;p=emacs.git Improve column width calculation in tabulated-list.el. * lisp/emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use string-width and truncate-string-width to handle arbitrary characters. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3ac04ab1492..07092bf5a51 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-03-20 Chong Yidong + + * emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use + string-width and truncate-string-width to handle arbitrary + characters. + 2012-03-20 Tassilo Horn * textmodes/artist.el (artist-menu-map): Bind Rectangle menu item diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 8fe514ab551..f17b12da6a0 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -278,11 +278,10 @@ of column descriptors." (width (nth 1 format)) (label (if (stringp desc) desc (car desc))) (help-echo (concat (car format) ": " label))) - ;; Truncate labels if necessary. - (and (> width 6) - (> (length label) width) - (setq label (concat (substring label 0 (- width 3)) - "..."))) + ;; Truncate labels if necessary (except last column). + (and (< (1+ n) len) + (> (string-width label) width) + (setq label (truncate-string-to-width label width nil nil t))) (setq label (bidi-string-mark-left-to-right label)) (if (stringp desc) (insert (propertize label 'help-echo help-echo))